home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Table / Sources / Proxy.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  6.8 KB  |  243 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Proxy.cpp
  4. //    Release Version:    $ ODF 3 $ 
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Table.hpp"
  11.  
  12. // ----- TablePart Includes -----
  13.  
  14. #ifndef PROXY_H
  15. #include "Proxy.h"
  16. #endif
  17.  
  18. #ifndef FRAME_H
  19. #include "Frame.h"
  20. #endif
  21.  
  22. #ifndef CONTENT_H
  23. #include "Content.h"
  24. #endif
  25.  
  26. // ----- Framework Includes -----
  27.  
  28. #ifndef FWFRMING_H
  29. #include "FWFrming.h"
  30. #endif
  31.  
  32. #ifndef FWITERS_H
  33. #include "FWIters.h"
  34. #endif
  35.  
  36. #ifndef FWUTIL_H
  37. #include "FWUtil.h"
  38. #endif
  39.  
  40. #ifndef FWFCTCLP_H
  41. #include "FWFctClp.h"
  42. #endif
  43.  
  44. #ifndef FWPXYFRM_H
  45. #include "FWPxyFrm.h"
  46. #endif
  47.  
  48. #ifndef FWTCOLL_H
  49. #include "FWTColl.h"
  50. #endif
  51.  
  52. // ----- OS Includes -----
  53.  
  54. #ifndef FWODGEOM_H
  55. #include "FWODGeom.h"
  56. #endif
  57.  
  58. #ifndef FWFXMATH_H
  59. #include "FWFxMath.h"
  60. #endif
  61.  
  62. //========================================================================================
  63. // Runtime Info
  64. //========================================================================================
  65.  
  66. #ifdef FW_BUILD_MAC
  67. #pragma segment odfTable
  68. #endif
  69.  
  70. //========================================================================================
  71. //    Template instantiations
  72. //========================================================================================
  73.  
  74. #include "FWTRCtCl.tpp"
  75.  
  76. FW_DEFINE_AUTO_TEMPLATE(FW_TRefCountedCollection, CTableProxy)
  77. FW_DEFINE_AUTO_TEMPLATE(FW_TRefCountedCollectionIterator, CTableProxy)
  78.  
  79. #if FW_USE_TEMPLATE_PRAGMAS
  80. #pragma template_access public
  81. #pragma template FW_TRefCountedCollection<CTableProxy>
  82. #pragma template FW_TRefCountedCollectionIterator<CTableProxy>
  83. #endif
  84.  
  85. #if FW_ANSI_TEMPLATE_INSTANTIATION
  86. template class FW_TRefCountedCollection<CTableProxy>;
  87. template class FW_TRefCountedCollectionIterator<CTableProxy>;
  88. #endif
  89.  
  90. //========================================================================================
  91. //    class CTableProxy
  92. //========================================================================================
  93.  
  94. //----------------------------------------------------------------------------------------
  95. //    CTableProxy::CTableProxy
  96. //----------------------------------------------------------------------------------------
  97.  
  98. CTableProxy::CTableProxy(Environment* ev, CTablePart* tablePart, CTablePartContent* tableContent) :
  99.     FW_MProxy(ev, tablePart),
  100.     fTablePart(tablePart),
  101.     fTableContent(tableContent),
  102.     fCell(0, 0),
  103.     fLinkSpecID(0)
  104. {
  105. }
  106.  
  107. //----------------------------------------------------------------------------------------
  108. //    CTableProxy::~CTableProxy
  109. //----------------------------------------------------------------------------------------
  110.  
  111. CTableProxy::~CTableProxy()
  112. {
  113. }
  114.  
  115. //----------------------------------------------------------------------------------------
  116. //    CTableProxy::UsedShapeChanged
  117. //----------------------------------------------------------------------------------------
  118.  
  119. void CTableProxy::UsedShapeChanged(Environment *ev,
  120.                                    FW_CEmbeddingFrame* embeddingFrame,
  121.                                    ODFrame* odEmbeddedFrame)
  122. {
  123. FW_UNUSED(odEmbeddedFrame);
  124.  
  125.     FW_CRect cellRect;
  126.     fTableContent->FindRect(fCell, cellRect);
  127.     FW_CAcquiredODShape aqInvalidShape = ::FW_NewODShape(ev, cellRect);
  128.  
  129. /*
  130.     FW_CAcquiredODShape aqUsedShape(FW_CopyAndRelease(ev, odEmbeddedFrame->AcquireUsedShape(ev, NULL)));
  131.         
  132.     // ----- For the Table part, all embedded facets have the same externalTransform
  133.     ODFacet *facet;
  134.     {
  135.         FW_CODFrameFacetIterator ite(ev, odEmbeddedFrame);
  136.         facet = ite.First(ev);
  137.     }
  138.     if (facet == NULL)
  139.         return;
  140.     
  141.     {
  142.         FW_CAcquiredODTransform aqExternalTransform(facet->AcquireExternalTransform(ev, NULL));
  143.         aqUsedShape->Transform(ev, aqExternalTransform);
  144.         aqInvalidShape->Subtract(ev, aqUsedShape);
  145.     }
  146. */
  147.  
  148.     // ----- Invalidate
  149.     embeddingFrame->Invalidate(ev, aqInvalidShape);
  150.     
  151.     // ----- Recalculate the clip
  152.     FW_CFacetClipper facetClipper;
  153.     facetClipper.Clip(ev, fTablePart->GetTablePresentation(ev), NULL);
  154. }
  155.  
  156. //----------------------------------------------------------------------------------------
  157. //    CTableProxy::FrameShapeRequested
  158. //----------------------------------------------------------------------------------------
  159.  
  160. ODShape* CTableProxy::FrameShapeRequested(Environment* ev, 
  161.                                         FW_CEmbeddingFrame* embeddingFrame, 
  162.                                         ODFrame* odEmbeddedFrame, 
  163.                                         ODShape* askedFrameShape)
  164. {
  165. FW_UNUSED(embeddingFrame);
  166. FW_UNUSED(askedFrameShape);
  167. FW_UNUSED(odEmbeddedFrame);
  168.  
  169.     FW_CRect cellRect;
  170.     fTableContent->FindRect(fCell, cellRect);
  171.  
  172.     cellRect.Place(FW_kZeroPoint);
  173.     ODShape* cellShape = ::FW_NewODShape(ev, cellRect);
  174.     
  175.     return cellShape;
  176. }
  177.  
  178. //----------------------------------------------------------------------------------------
  179. //    CTableProxy::MoveEmbeddedFrames
  180. //----------------------------------------------------------------------------------------
  181.  
  182. void CTableProxy::MoveEmbeddedFrames(Environment* ev, const CCell& destCell)
  183. {
  184.     FW_CRect rect;
  185.     fTableContent->FindRect(destCell, rect);
  186.     ChangeFrameShapes(ev, rect.Width(), rect.Height());
  187.     ChangeExternalTransforms(ev, rect.left, rect.top);
  188.     
  189.     //     [HLX] because I can't create facets with a NULL clip (bug in OpenDoc???) I have to 
  190.     //    Clip my embedded facets everytime
  191.     FW_CFacetClipper facetClipper;
  192.     facetClipper.Clip(ev, fTablePart->GetTablePresentation(ev), NULL);
  193. }
  194.  
  195. //----------------------------------------------------------------------------------------
  196. //    CTableProxy::AcquireHiliteShape
  197. //----------------------------------------------------------------------------------------
  198.  
  199. ODShape* CTableProxy::AcquireHiliteShape(Environment* ev, const CCell& cell, FW_CEmbeddingFrame* frame)
  200. {
  201.     FW_CRect rect;
  202.     fTableContent->FindRect(cell, rect);
  203.  
  204.     FW_CAcquiredODFrame embeddedFrame = this->AcquireEmbeddedFrame(ev, frame);
  205.     FW_CAcquiredODShape usedShape = FW_CopyAndRelease(ev, embeddedFrame->AcquireUsedShape(ev, NULL));
  206.     FW_CAcquiredODTransform transform = ::FW_NewODTransform(ev, rect.TopLeft());
  207.     usedShape->Transform(ev, transform);
  208.     ODShape* hiliteShape = ::FW_NewODShape(ev, rect);
  209.     hiliteShape->Subtract(ev, usedShape);
  210.     return hiliteShape;
  211. }
  212.  
  213. //----------------------------------------------------------------------------------------
  214. //    CTableProxy::CreateFacets
  215. //----------------------------------------------------------------------------------------
  216.  
  217. short CTableProxy::CreateFacets(Environment* ev,
  218.                                 FW_CEmbeddingFrame* embeddingFrame,
  219.                                 ODFacet* embeddingFacet,
  220.                                 ODFrame* embeddedFrame,
  221.                                 ODShape* proposedClipShape)
  222. {
  223. FW_UNUSED(embeddingFrame);
  224.     FW_CRect rect;
  225.     fTableContent->FindRect(fCell, rect);
  226.     
  227.     FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, rect.TopLeft());
  228.  
  229.     CreateFacet(ev,
  230.                 embeddingFacet,
  231.                 embeddedFrame,
  232.                 proposedClipShape,
  233.                 aqExternalTransform,
  234.                 NULL,                    // Canvas
  235.                 NULL,                    // biasCanvas
  236.                 NULL,                    // siblingFacet
  237.                 kODFrameInFront);
  238.     return 1;
  239. }
  240.  
  241.  
  242.  
  243.